
// 主题切换工具类
export const ThemeUtil = {
  // 当前主题
  currentTheme: 'light',

  // 切换主题
  toggleTheme() {
    const theme = this.currentTheme === 'light' ? 'dark' : 'light'
    this.setTheme(theme)
  },

  // 设置主题
  setTheme(theme) {
    this.currentTheme = theme
    document.documentElement.setAttribute('data-theme', theme)
    localStorage.setItem('theme', theme)
  },

  // 初始化主题
  initTheme() {
    const savedTheme = localStorage.getItem('theme') || 'light'
    this.setTheme(savedTheme)
  }
}
